package blackhouse.laobi.regex.day25;

import java.net.*;
import java.io.*;
import java.util.regex.*;

public class RegexTest2 {
 
	public static void main(String[] args) throws Exception {
		  getMails_1();
	}
    public static void getMails_1() throws Exception{
    	URL url = new URL("http://localhost:8080/myweb/mail.html");
    	
    	URLConnection conn = url.openConnection();
    	
    	BufferedReader bufIn =new BufferedReader(new InputStreamReader(conn.getInputStream()));
    	
    	String line = null;
    	
    	String mailReg ="\\w+@\\w+(\\.\\w+)+";
    	Pattern p = Pattern.compile(mailReg);
    	
    	while((line =bufIn.readLine())!=null){
    		Matcher m = p.matcher(line);
    		while(m.find()){
    			System.out.println(m.group());
    		}
    	}
    }
}
